<?php namespace app\admin\controller;

class Module{
//    模块类
    protected $class;
//    模块动作
    protected $action;
//    构造函数
    public function __construct()
    {
        $info = explode('/',Request::get('a'));
        $this->class = 'module\\' . Request::get('m') . '\\' . ucfirst($info[0]);
        $this->action = $info[1];

    }

//    检测执行那个模块
    public function entry(){
        switch (Request::get(t)){
            case 'admin':
                $this->admin();
                break;
            case 'web':
                $this->web();
                break;
        }
    }

//    后台访问动作
    protected function admin(){
//        检测用户是否登陆
        User::isLogin();
        $class = $this->class;
        $action = 'admin' . $this->action;
        $obj = new $class;
        $obj->$action();
    }



//    前台访问动作
    protected function web(){
        $class = $this->class;
        $action = 'web' . $this->action;
        $obj = new $class;
        $obj->$action();
    }

}